#!/bin/bash
set -e

# compile occallcj.cj
export lib_path="${1}"
export CONFIGURATION="${4}"
BUILD_TYPE="debug"
if [[ "$CONFIGURATION" == "Release" ]]; then
    BUILD_TYPE="release"
fi
bash ${lib_path}/build.sh ${BUILD_TYPE}

# embed and sign dylibs
export PROJECT_DIR="${2}/.."
export TARGET_NAME="${3}"
echo "PROJECT_DIR : ${PROJECT_DIR}"
echo "TARGET_NAME : ${TARGET_NAME}"
ruby ${PROJECT_DIR}/link-embed-libraries.rb "${PROJECT_DIR}" "${TARGET_NAME}"